From fe3922d039bdb5d4c063bc73543abc53a57d8464 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Fri, 22 Jul 2022 18:32:53 +0200
Subject: fix(comments): refresh comments on changes or new comment

---
 src/pages/article/[slug].tsx | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'src/pages/article/[slug].tsx')

diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx
index ea679ab..f720fa6 100644
--- a/src/pages/article/[slug].tsx
+++ b/src/pages/article/[slug].tsx
@@ -26,6 +26,7 @@ import {
   getWebPageSchema,
 } from '@utils/helpers/schema-org';
 import useBreadcrumb from '@utils/hooks/use-breadcrumb';
+import useComments from '@utils/hooks/use-comments';
 import usePrism, { type OptionalPrismPlugin } from '@utils/hooks/use-prism';
 import useReadingTime from '@utils/hooks/use-reading-time';
 import useSettings from '@utils/hooks/use-settings';
@@ -58,9 +59,7 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({
   const { data: article } = useSWR(() => slug, getArticleBySlug, {
     fallbackData: post,
   });
-  const { data: commentsData } = useSWR(() => id, getPostComments, {
-    fallbackData: comments,
-  });
+  const commentsData = useComments(post.id, comments);
   const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({
     title: article?.title || '',
     url: `/article/${slug}`,
-- 
cgit v1.2.3

